<template>
  <div class="swiper-container" ref="swiper-container" :style="{height : height + 'px'}">
    <div class="swiper-wrapper">
      <!-- 插槽 -->
      <slot></slot>
    </div>
  </div>
</template>

<script>
import Swiper from "swiper";
import "swiper/swiper-bundle.min.css";
export default {
  props: {
      preview : {
          type:Number,
          default : 1
      },
      height: {
          type:Number,
          default: 200
      },
      iscenter:{
        type:Boolean,
        default: false
      }
  },
  mounted() {
    // 等待所有的异步操作全部完成后，执行，再次可以得到真实dom数据
    this.$nextTick(() => {
      var mySwiper = new Swiper(this.$refs["swiper-container"], {
        loop: false,
        // 一屏显示几个图片
        slidesPerView: this.preview,
        spaceBetween: 10,
        centeredSlides: this.iscenter,
        slideToClickedSlide: true,
      });
    });
  },
};
</script>

<style lang="scss">
.swiper-container {
  width: 100%;
  background: rgb(255, 255, 255);
  .swiper-slide {
      margin-right: 10px;
    .actors-img {
      width: 85px;
      height: 85px;
      background: rgb(249, 249, 249);
      position: relative;
      overflow: hidden;
      img {
        width: 100%;
        position: absolute;
        top: 50%;
        margin-top: -60px;
      }
    }
    .photos-img{
        width: 160px;
        height: 100%;
        img {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 50%;
        margin-top: -60px;
      }
    }
    
    
    span {
      display: block;
      text-align: center;
    }
    .actors-name {
      padding-top: 10px;
      font-size: 12px;
      color: #191a1b;
      width: 85px;
      height: 18px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .actors-role {
      font-size: 10px;
      color: #797d82;
    }
  }
}
</style>